 var facebookGraphURL = 'https://graph.facebook.com/';

window.fbAsyncInit = function() {
  FB.init({
    appId      : '514645711902182', // App ID
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
  });

  FB.Event.subscribe('auth.statusChange', handleStatusChange);

  FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
      document.body.className = 'connected';
    }
    else {
      document.body.className = 'not_connected';
    } 
  });

  function handleStatusChange(response) {
    document.body.className = response.authResponse ? 'connected' : 'not_connected';
    if (response.authResponse) {
      $('#lstvwWallFeed').fbWall({
        id: response.authResponse.userID,
        accessToken: response.authResponse.accessToken,
        showGuestEntries: true,
        showComments: true,
        max: 25,
        timeConversion: 12
      });
    }
  }
};

function loginUser() {
  FB.login(function(response) { }, {scope:'read_stream'});     
}

// Load the SDK Asynchronously
(function(d) {
  var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
  if (d.getElementById(id)) {
    return;
  }
  js = d.createElement('script'); js.id = id; js.async = true;
  js.src = "//connect.facebook.net/en_US/all.js";
  ref.parentNode.insertBefore(js, ref);
}(document));